Implement _timeout and _ready for WIN32 to help geriatric garmins that
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Wed, 22 Dec 2004 19:27:23 +0000 (19:27 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Wed, 22 Dec 2004 19:27:23 +0000 (19:27 +0000)
may or may not respond to A001's.

gpsbabel/jeeps/gpsserial.c

index f7d5d631a7fc87ff667ff9af6154280a3981f170..91451311caca82f06df0eb633cdff3039d169c7c 100644 (file)
@@ -135,6 +135,7 @@ int32 GPS_Serial_On(const char *port, int32 *fd)
         * (i.e. cable unplugged, unit not turned on) values.
         */
        GetCommTimeouts (comport, &timeout);
+
        timeout.ReadIntervalTimeout = 1000; /*like vtime.  In MS. */
        timeout.ReadTotalTimeoutMultiplier = 1000;
        timeout.ReadTotalTimeoutConstant = 1000;
@@ -164,12 +165,24 @@ int32 GPS_Serial_Off(const char *port, int32 fd)
 
 int32 GPS_Serial_Chars_Ready(int32 fd)
 {
-       return 1;
+       COMSTAT lpStat;
+       DWORD lpErrors;
+
+       ClearCommError(comport, &lpErrors, &lpStat);
+       return (lpStat.cbInQue > 0);
 }
 
 int32 GPS_Serial_Wait(int32 fd)
 {
-       return 1;
+       /* Wait a short time before testing if data is ready.
+        * The GPS II, in particular, has a noticable time responding
+        * with a response to the device inquiry and if we give up on this
+        * too soon, we fail to read the response to the A001 packet and
+        * blow our state machines when it starts streaming the capabiilties
+        * response packet.
+        */
+       Sleep(usecDELAY / 1000);
+       return GPS_Serial_Chars_Ready(fd);
 }
 
 int32 GPS_Serial_Flush(int32 fd)